// 对路由处理将其转为需要的类型
let finalRouteList = []
export function getRouteList(routes) {
  let routeList = []
  routes.forEach((item, index) => {
    const { path, name } = item
    const route = {
      path,
      name,
      component: () =>
        import(/* webpackChunkName: "list" */ `../views/${item.component}.vue`)
    }
    routeList.push(route)
    if (item.children && item.children.length) {
      route.children = getRouteList(item.children)
      route.component = () =>
        import(/* webpackChunkName: "list" */ `../${item.component}`)
      route.redirect = `/${item.children[0].component}`
      finalRouteList.push(route)
    }
  })
  return routeList
}
